<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<link href="/webjars/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<script src="webjars/jquery/3.4.1/jquery.js"></script>
<script src="webjars/jquery-cookie/1.4.1-1/jquery.cookie.js"></script>
<script type="text/javascript" src="/webjars/vue/2.6.10/dist/vue.js"></script>
<script type="text/javascript" src="/webjars/axios/0.19.0/dist/axios.js"></script>
<style>
    body{
        text-align: center;
    }
</style>
<body>

<div id="app">

    <h1>添加常见问题</h1><br><br>
    分类:
    <select v-model="fenlei.classId">
        <option selected="selected">--请选择分类--</option>
        <option  v-for="item in data" :value="item.id">{{item.cname}}</option>
    </select><br><br>
    标题:<input type="text" v-model="fenlei.title"><br><br>
    内容:<textarea rows="3" cols="20" v-model="fenlei.content"> </textarea><br><br>

    <input type="button" @click="Add()" value="保存">  &nbsp;&nbsp;<input type="button" value="放弃">

</div>

</body>
</html>
<script>
    var vue = new Vue({
        el:"#app",
        data:{
            data:{},
            fenlei:{title:"",content:"",createDate:"",classId:0}
        },methods:{
            selectFenLei:function () {
                axios.get("/select2").then(res=>{
                    console.log(res.data.list)
                    this.data = res.data.list
                });
            },
            Add:function () {
                axios.post("/add",this.fenlei).then(res=>{
                        window.location.href="http://localhost:8080/list.html";
                })

            }
        },mounted:function(){
            this.selectFenLei();
        }
    });
</script>